package test;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;

public class CallWindow extends JFrame {
	JButton button;
	JFrame frame;
	boolean called = false;
	final static boolean CALLED = true;
	final static boolean NEW_MESS = false;

	public CallWindow(JFrame frame) throws HeadlessException {
		super();
		this.frame = frame;
		// this.button = new JButton(new
		// ImageIcon(this.getClass().getResource("/test/arrow.png").getFile()));
		this.button = new JButton(new ImageIcon(Toolkit.getDefaultToolkit()
				.getImage(RunServer.class.getResource("/test/arrow.png"))));
		// button.setFont(new Font("Times New Roman", Font.BOLD, 50));
		this.getContentPane().add(button);
		this.setSize(150, 150);
		this.setDefaultCloseOperation(HIDE_ON_CLOSE);
		// this.setResizable(false);
		// this.setVisible(true);
		this.setAlwaysOnTop(true);
		button.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				CallWindow.this.setVisible(false);
				if (called != CALLED) {
					CallWindow.this.frame.setState(JFrame.ICONIFIED);
					CallWindow.this.frame.setState(JFrame.NORMAL);
				} else {
					CallWindow.this.frame.setState(JFrame.ICONIFIED);
				}
			}
		});
	}

	public void changeToCall() {
		button.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().getImage(
				RunServer.class.getResource("/test/arrow.png"))));
	}

	public void changeToNewMess() {
		button.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().getImage(
				RunServer.class.getResource("/test/mail.png"))));
	}

	public boolean isCalled() {
		return called;
	}

	public void setCalled(boolean called) {
		this.called = called;
	}

	
}
